package com.young.shop_admin.controller;

import com.alibaba.fastjson.JSON;
import com.young.shop_admin.pojo.entity.Order;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/orderList.do")
public class OrderListController extends BaseController {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取数据库订单表
        List<Order> OrderItems = orderList.getAllOrders();
        //返回数据转换为json并写入输出流
        String json = JSON.toJSONString(OrderItems);
        //解决跨域问题
        resp.setHeader("Access-Control-Allow-Origin","http://localhost:63342");
        System.out.println(json);
        writerSuccessResult(OrderItems,resp);
    }
}
